﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Workflow.Activities;
using Argos.Data.Model;
using Argos.Scheduling;

namespace Argos.WorkflowServices
{
	/// <summary>
	/// Defines the interface that is implemented by a service that provides data to monitoring
	/// workflow instances.
	/// </summary>
	/// <remarks>
	/// It is recommended that implementers do not implement this interface directly but instead
	/// extend the class <see cref="StorageServiceBase"/>.
	/// </remarks>
	[ExternalDataExchange]
	public interface IStorageService
	{

		/// <summary>
		/// When implemented in a class, returns the backup route for the given route.
		/// </summary>
		/// <remarks>
		/// If the route specified in <paramref name="routeId"/> does not have a backup route, an
		/// implementation of this class must return null.
		/// </remarks>
		/// <param name="routeId">The ID of the route for which to return the backup route.</param>
		MessageDeliveryRoute GetMessageDeliveryRouteBackup(Guid routeId);

		/// <summary>
		/// When implemented in a class, returns a list of recipients for the given target
		/// and type of alert.
		/// </summary>
		/// <param name="targetId">The ID of the target whose recipients to return.</param>
		/// <param name="alertType">The type of alert for which to return the recipients.</param>
		List<Recipient> GetRecipients(Guid targetId, AlertTypes alertType);

		/// <summary>
		/// When implemented in a class, returns the target with the given ID.
		/// </summary>
		/// <param name="targetId">The ID of the target to return.</param>
		/// <returns>
		/// Returns the given target. If a target with the given ID is not found, an
		/// implementation of this method must return null.
		/// </returns>
		Target GetTarget(Guid targetId);

		/// <summary>
		/// when implemented in a class, returns a list of schedules that define when a target is
		/// being monitored. The given target will not be monitored until at least one of the
		/// schedules in the list return a current occurrence.
		/// </summary>
		/// <param name="targetId">The ID of the target whose monitoring schedules to return.</param>
		/// <returns>
		/// Returns a list of schedules. If the list is null or empty, the target will have no
		/// scheduled occurrences when it will be monitored, i.e. the target is effectively paused.
		/// </returns>
		List<Schedule> GetTargetActiveSchedules(Guid targetId);

		/// <summary>
		/// When implemented in a class, returns a list of schedules that define scheduled monitoring
		/// breaks for the given target.
		/// </summary>
		/// <remarks>
		/// If the list contains at least one schedule that defines a current occurrence, the
		/// monitoring for the given target is assumed to be in a break. During a break, monitoring
		/// for the given target will not be performed.
		/// </remarks>
		/// <param name="targetId">The ID of the target whose break schedules to return.</param>
		/// <returns>
		/// Returns a list of schedules. If the returned list is null or empty, the target is
		/// assumed to have no breaks.
		/// </returns>
		List<Schedule> GetTargetBreakSchedules(Guid targetId);

		/// <summary>
		/// when implemented in a class, returns the test for the target with the given ID.
		/// </summary>
		/// <param name="targetId">The ID of the target whose test to return.</param>
		Test GetTargetTest(Guid targetId);

		/// <summary>
		/// When implemented in a class, stores the test state for the given target.
		/// </summary>
		/// <param name="targetId">The ID of the target whose test state is being stored.</param>
		/// <param name="testState">The test state to store.</param>
		void StoreTestState(Guid targetId, object testState);

	}
}
